package com.jasperframework.boot.common.utils;

import org.apache.commons.lang3.StringUtils;

import java.io.File;

/**
  * <p> 统一不同平台下的文件分隔符  </p>
  *
  * @site https://miliqkdoc.motopa.cn/
  * @author daizhao
  * @date 2022/12/12 12:12
  */
public class FileSeparatorUtil {

    public static String replaceFileSeparator(String path){
        String tempPath = "";
        if(StringUtils.isNotBlank(path)){
            if(path.contains("/")) {//linux
                tempPath = path.replace("/", File.separator);
            }
            if(path.contains("\\")){//windows
                tempPath = path.replace("\\", File.separator);
            }
        }
        return tempPath;
    }
}
